from sympy import symbols, summation, simplify, limit, oo

if __name__ == '__main__':
    # 定义单个符号
    # n = Symbol("n")
    #
    # k = Symbol("k")

    # 定义多个符号
    n, k = symbols("n k")

    sum_expression = summation(k / n ** 2, (k, 1, n))

    # (n**2/2 + n/2)/n**2
    print(sum_expression)

    simplify_expression = simplify(sum_expression)
    # (n + 1)/(2*n)
    print(simplify_expression)

    result = limit(simplify_expression, n, oo, dir="+")
    print(result)
